var username=localStorage.getItem("username");
var token=localStorage.getItem("token");
var userid=localStorage.getItem("userid");
$(function(){
	$("#preRecvTime").datetimepicker({lang:'ch',
		timepicker:false,
		format:'Y-m-d',
		formatDate:'Y-m-d'
	});

	var paramMap = params();
	var id = paramMap['productId'];
	$("#backList").click(function(){
		var url=server_url+'/weixinproductList.do';
		tl_config.last_url=url;
		tl_config.loadToWorkArea(url);
	});

	debugger
	$.ajax({
		type : 'GET',
		contentType : 'application/json',
		async : false,
		data : {
			productId : id,
			token:token
		},
		url : server_url+'/rest/tea/product/getTeaProductInfo.do?ran='+Math.random(),
		dataType : 'json',
		success : function(data) {
			if (data.retCode == "0000") {
				pasteData(data.data);
			} else{
				easyDialog.open({
					container:{
						header:'温馨提示',
						content:data.retMsg
					},
					autoClose : 2000
				});
			}
		}
	});
	
});

function isEmpty(data){
	if(data==null||data==undefined||data.length==0){
		return true;
	}else{
		return false;
	}
}
function pasteData(data){
	debugger
	console.log(data);
    //var order=data.order.data;

    $("#id").val(data.id);
	$("#orderCode").text(data.productid);
	if(data.status == "1"){
		$("#orderStatusName").text("已发布");
	}else{
		$("#orderStatusName").text("未发布");
	}
	$("#usersName").text(data.legalName);
	$("#preRecvTime").val(data.addtime);
	$("#price").val(data.teaPrice);
	$("#teaArea").val(data.teaArea);
	$("#teaLocation").val(data.teaLocation);
	$("#teaAge").val(data.teaAge);
	$("#teaYear").val(data.teaYear);
	$("#treeNum").val(data.treeNum);
	$("#coverArea").val(data.coverArea);
	
	
	$("#picturePath1").attr("src",data.productPic.coverPic);
	$("#picturePath2").attr("src",data.productPic.picturepath1);
	$("#picturePath3").attr("src",data.productPic.cshjPic);

};
function back(){
	var url=server_url+'orderManage/list.do';
	tl_config.loadToWorkArea(url);
}

//刷新当前页面
var reloadFn = function(){
	window.location.reload();
};
